home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TGCBOR20.ARJ / TUTOR.COM / ICONS.TXT < prev    next >
Text File  |  1991-08-27  |  4KB  |  143 lines

  1. ICONS
  2. -------------------------------------------------------------------
  3.  
  4. Icons are a special kind of image that are drawn as they are used, they
  5. are not stored as bit images.
  6.  
  7. Icons are created with the ICON Editor. The ICON editor is included
  8. with the TEGL Windows Toolkit but is not included with the Intro Paks.
  9.  
  10. void putpict(unsigned x, unsigned y, char *icon, unsigned color);
  11.  
  12. putpict is the routine that draws an icon. The x,y parameters are the
  13. screen location to draw at. Icon points to a valid icon image, there
  14. is no checking done to see if the icon is a correct image. Color is
  15. the color that BLACK in the icon will be replaced with.
  16.  
  17. putpict is NOT viewport relative and is never clipped.
  18.  
  19.  
  20. These are all the icons in teglicon.tpu and moreicon.tpu. Note that
  21. the actual name to refer to an icon is image<iconname>.
  22.  
  23. ARROWDN        ARROWLF         ARROWRT         ARROWUP
  24. BAR            BELL            BELL2           BLANKBUT
  25. BULB           C               CANCEL          CHK7X6
  26. CHK8X10        CHK8X12         CHK8X8          CLOCK
  27. COMPUTER       CORNER          CORNER2         CORNER3
  28. CREDITS        DISK            DISK35          DISKDRV
  29. DOCUMENT       DOWN            DRAWER          FILE
  30. FIND           KEYBOARD        KEYBRD2         LAST
  31. LBUT           LEFT            MBUT            MC
  32. MONITOR        MOUSE           MOUSE2          MUSIC
  33. MUSIC2         NEXT            NOTE            NOTE2
  34. OK             PREV            PRINTER         QUESTN2
  35. R              RBUT            READ            RESIZE
  36. RIGHT          SLIDER          SLIDER2         STOPSIGN
  37. SUBMENU        SYSTEM          TIGER           TINYTEGL
  38. TRASH          UP              VS              WFDN
  39. WFUP           WFICON          WFLF            WFRT
  40. WFUD           WFBAR           WRITE           WFMDN
  41.  
  42.  
  43.  
  44. This example simply create a frame a sticks an icon on it.
  45. Note that we use the x and y coordiates from the imagestkptr
  46. to place the iconimage.
  47.  
  48.  
  49. BEGINFILE> icon1.c
  50.   /* -- icon1.pas */
  51.  
  52. #include "teglsys.h"
  53.  
  54.  
  55. imagestkptr  ifs;
  56.  
  57.  
  58. void main(void)
  59. {
  60.   unsigned x1 = 100;
  61.   unsigned y1 = 100;
  62.   unsigned x2 = 110;
  63.   unsigned y2 = 100;
  64.  
  65.   easytegl();
  66.   easyout();
  67.   quickframe(&ifs,&x1,&y1,&x2,&y2);
  68.  
  69.     /* -- use the frames x and y fields to draw the icon  */
  70.     /* -- in a relative position  */
  71.  
  72.   putpict(ifs->x + 10,ifs->y + 10,imageSYSTEM,BLACK);
  73.  
  74.  
  75.   teglsupervisor();
  76. }
  77.  
  78.  
  79.  
  80. ENDFILE>
  81.  
  82. void pictsize(unsigned *width, unsigned *height, char *icon);
  83.  
  84. This function returns the size of an icon in pixels. Icon is the
  85. icon that we are interrogating. width and height return the
  86. respective x and y dimentions of the icon.
  87.  
  88.  
  89. This next example shows a routine that draws an icon relative to
  90. a frame and won't write outside the frame boundaries.
  91.  
  92. BEGINFILE> icon2.c
  93.   /* -- icon2.pas */
  94.  
  95. #include "teglsys.h"
  96.  
  97.   /* -- draw an icon image relative to a frame, do not draw it if  */
  98.   /* -- it writes outside the frame  */
  99.  
  100.  
  101. void putpictrel(imagestkptr  ifs, unsigned x, unsigned y,
  102.                         void *icon, unsigned color)
  103.   { unsigned     dx, dy;
  104.     unsigned      fmaxx, fmaxy;
  105.  
  106.     pictsize(&dx,&dy,icon);
  107.     fmaxx = ifs->x1 - ifs->x + 1;
  108.     fmaxy = ifs->y1 - ifs->y + 1;
  109.       /* -- check to see the icon will fit  */
  110.     if (((x + dx) > fmaxx) || ((y + dy) > fmaxy)) return;
  111.     putpict(ifs->x + x,ifs->y + y,icon,color);
  112.   }
  113.  
  114. imagestkptr  ifs;
  115.  
  116. void main(void)
  117. {
  118.   unsigned x1 = 100;
  119.   unsigned y1 = 100;
  120.   unsigned x2 = 110;
  121.   unsigned y2 = 100;
  122.  
  123.  
  124.   easytegl();
  125.   easyout();
  126.   quickframe(&ifs,&x1,&y1,&x2,&y2);
  127.  
  128.     /* -- use the frames x and y fields to draw the icon  */
  129.     /* -- in a relative position  */
  130.  
  131.   putpictrel(ifs,10,10,imageSYSTEM,BLACK);
  132.  
  133.  
  134.   teglsupervisor();
  135. }
  136.  
  137.  
  138.  
  139. ENDFILE>
  140.  
  141. ----------------------------------------------------------------------
  142. END ICONS
  143.